<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *公告
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$tabs=array(
	array('op'=>'list','title'=>'公告列表'),
);
//公告
if($_RQ['op']=='list'){
	$params=array('status'=>1);
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	if(!empty($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','title','image','status');
	$list=pdo_getslice('jy_baobiao_notice',$params,array($pindex,$psize),$total,$fields);
	if($list){
		foreach($list as &$item){
			$item['url']=custom_url('core/article.list/detail//id='.$item['id'],true);
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
		//	array('name'=>'paixu','title'=>'顺序','type'=>'string'),
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'image','title'=>'图片','type'=>'image'),
			array('name'=>'url','title'=>'链接地址','type'=>'copy'),
		),'action' =>array(
			array('type'=>'href','op'=>'look','title'=>'查看详细'),
		)),
		'search'=>array(
			array('name'=>'title','width'=>15,'title'=>'标题','type'=>'string'),
		)
	);
	$return['status']=array('0'=>'隐藏','1'=>'显示');
	$return['status2']=array(array('id'=>0,'title'=>'隐藏'),array('id'=>1,'title'=>'显示'));
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='look'){
	$return=array();
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_baobiao_notice',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}else{
		$item=array();
	}
	$return['item']=$item;
	$htmls=array(
		'type'=>'look',
		'tabs'=>array(
			array('op'=>'list','title'=>'返回公告列表'),
		),
		'look'=>array(
			array('type'=>'string','title'=>'标题','name'=>'title','help'=>''),
			array('type'=>'image','title'=>'公告图片','name'=>'image','help'=>''),
			array('type'=>'richtext','title'=>'公告内容','name'=>'content','help'=>''),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}